package com.nacrtstudio.webgiftshop.model.shop.beans;

import java.util.Date;
import java.util.List;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

import com.nacrtstudio.webgiftshop.core.beans.BaseBean;
import com.nacrtstudio.webgiftshop.model.shop.Cart;
import com.nacrtstudio.webgiftshop.model.shop.CartItem;
import com.nacrtstudio.webgiftshop.model.shop.Category;
import com.nacrtstudio.webgiftshop.model.shop.Comment;
import com.nacrtstudio.webgiftshop.model.shop.Gift;
import com.nacrtstudio.webgiftshop.model.shop.PackedGift;
@Entity
public class GiftBean extends BaseBean implements Gift{
	private Long giftId;
	private Date date = new Date();
	private String giftName;
	private String description;
	private String imgPath="layout/images/default.jpg";
	private String altText;
	private boolean specialContent;
	private Set<PackedGift> packedGifts;
	
	private Category category;
	private List<String> imgsOfGiftContent;
	private Double price;
	
	private Set<Comment> comments;
	private Set<CartItem> cartItems;
	
	private int howManyTimesIsChosen;
	
	private boolean status;

	public Long getGiftId() {
		return giftId;
	}

	public void setGiftId(Long giftId) {
		this.giftId = giftId;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public String getGiftName() {
		return giftName;
	}

	public void setGiftName(String giftName) {
		this.giftName = giftName;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getImgPath() {
		return imgPath;
	}

	public void setImgPath(String imgPath) {
		this.imgPath = imgPath;
	}

	public String getAltText() {
		return altText;
	}

	public void setAltText(String altText) {
		this.altText = altText;
	}

	@ManyToOne(targetEntity=CategoryBean.class)
	public Category getCategory() {
		return category;
	}

	public void setCategory(Category category) {
		this.category = category;
	}
	@ElementCollection
	@CollectionTable(name="GiftContent", joinColumns=@JoinColumn(name="giftId"))
	@Column(name="content")
	@LazyCollection(LazyCollectionOption.FALSE)
	public List<String> getImgsOfGiftContent() {
		return imgsOfGiftContent;
	}

	public void setImgsOfGiftContent(List<String> imgsOfGiftContent) {
		this.imgsOfGiftContent = imgsOfGiftContent;
	}

	public Double getPrice() {
		return price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}
	@OneToMany(cascade=CascadeType.ALL, targetEntity=CommentBean.class)
	public Set<Comment> getComments() {
		return comments;
	}

	public void setComments(Set<Comment> comments) {
		this.comments = comments;
	}
	
	@OneToMany(mappedBy="gift", cascade=CascadeType.DETACH, targetEntity=CartItemBean.class)
	public Set<CartItem> getCartItems() {
		return cartItems;
	}

	public void setCartItems(Set<CartItem> cartItems) {
		this.cartItems = cartItems;
	}

	public int getHowManyTimesIsChosen() {
		return howManyTimesIsChosen;
	}

	public void setHowManyTimesIsChosen(int howManyTimesIsChosen) {
		this.howManyTimesIsChosen = howManyTimesIsChosen;
	}
	
	@OneToMany(targetEntity=PackedGiftBean.class)
	public Set<PackedGift> getPackedGifts() {
		return packedGifts;
	}

	public void setPackedGifts(Set<PackedGift> packedGifts) {
		this.packedGifts = packedGifts;
	}

	public boolean isStatus() {
		return status;
	}

	public void setStatus(boolean status) {
		this.status = status;
	}

	public boolean isSpecialContent() {
		return specialContent;
	}

	public void setSpecialContent(boolean specialContent) {
		this.specialContent = specialContent;
	}
}
